import request from '@/utils/request'
import { getToken } from '@/utils/auth'

export function GetPermissionTree() {
  return request({
    url: '/api/admin/GetPermissionTree',
    method: 'get',
    headers: {
      Token: getToken()
    }
  })
}

export function GetRoleList(search_name, page, limit) {
  return request({
    url: '/api/admin/GetRoleList',
    method: 'get',
    headers: {
      Token: getToken()
    },
    params: { 'val': search_name, 'page': page, 'limit': limit }
  })
}

export function addRole(data, tree) {
  return request({
    url: '/api/admin/addRole',
    method: 'post',
    headers: {
      Token: getToken()
    },
    data: { 'data': data, 'tree': tree }
  })
}

export function updateRole(data, tree) {
  return request({
    url: '/api/admin/updateRole',
    method: 'post',
    headers: {
      Token: getToken()
    },
    data: { 'data': data, 'tree': tree }
  })
}

export function CheckRoleStatus(status, id) {
  return request({
    url: '/api/admin/CheckRoleStatus',
    method: 'post',
    headers: {
      Token: getToken()
    },
    params: { 'status': status, 'id': id }
  })
}
export function GetRoleOption() {
  return request({
    url: '/api/admin/GetRoleOption',
    method: 'get',
    headers: {
      Token: getToken()
    }
  })
}

export function GetCheckedTree(id) {
  return request({
    url: '/api/admin/GetCheckedTree',
    method: 'get',
    headers: {
      Token: getToken()
    },
    params: { 'role_id': id }
  })
}

export function DelRole(id) {
  return request({
    url: '/api/admin/DelRole',
    method: 'post',
    data: { 'role_id': id },
    headers: {
      Token: getToken()
    }
  })
}

